<?php
use Core\Common\Common;
use Core\Enums\DigitEnum;

error_reporting(E_ALL^E_NOTICE^E_WARNING);
date_default_timezone_set('Asia/Shanghai');
header("Content-type:text/html;charset=utf-8");
function loadFielEndOfPhp($class_name) {
    require_once('' . str_replace("\\","/",$class_name) . '.class.php');
}
spl_autoload_register(loadFielEndOfPhp);
$path = __DIR__ . \DIRECTORY_SEPARATOR . './' . \DIRECTORY_SEPARATOR . 'vendor' . \DIRECTORY_SEPARATOR . 'autoload.php';
if (file_exists($path)) {
    require_once $path;
}
require_once "./SendSms/src/Sample.php";
class crm
{
    function __construct(){
        $POST = Common::getPost();
        $POST["token"] = $this->NginxGetAllHeaders()["Token"];
        $REQUEST_URI = explode("/",$_SERVER['REQUEST_URI']);
        $TARGET=$REQUEST_URI[1];
        $METHOD=$REQUEST_URI[2];
        if(!empty($TARGET)){
            $OBJECTOR = "App\Controller\Admin\\".$REQUEST_URI[1];
            $OBJECT = new $OBJECTOR();
            if(method_exists($OBJECT,$METHOD))
                echo $OBJECT->$METHOD($POST);
        }
    }
    function NginxGetAllHeaders(){//获取请求头
        $headers = [];
        foreach ($_SERVER as $name => $value){
            if (substr($name, 0, 5) == 'HTTP_'){
                $headers[str_replace(' ', '-', ucwords(strtolower(str_replace('_', ' ', substr($name, 5)))))] = $value;
            }
        }
        return $headers;
    }
}
new crm();
